#include "ExcelVisitorIterator.h"
#include "../StaticData/SimpleTableFrame.h"

CExcelVisitorIterator::CExcelVisitorIterator( IExcelVisitor& rVisitor,int nRowBegin )
:m_rVisitor(rVisitor)
,m_pFrame(0)
,m_rFrame( GenerateTableFrame() )
{
	Reset ( nRowBegin );
}


CExcelVisitorIterator::CExcelVisitorIterator( IExcelVisitor& rVisitor,ISimpleTableFrame& rFrame,int nRowBegin )
:m_rVisitor(rVisitor),
m_rFrame(rFrame)
{
	m_pFrame = 0;
	Reset ( nRowBegin );
}

CExcelVisitorIterator::~CExcelVisitorIterator()
{
	if( m_pFrame ) delete m_pFrame;
}

ISimpleTableFrame&	CExcelVisitorIterator::GenerateTableFrame()
{
	//if( m_pFrame ) delete m_pFrame;

	m_pFrame = new CSimpleTableFrame;
	int nColCount = Visitor().GetColSize();
	for( int c=0;c<nColCount;c++ )
	{
		std::string strField;
		Visitor().GetCellString( strField,1,c+1 );
		m_pFrame -> AddPair( strField,c+1 ) ;
	}

	return *m_pFrame;
}
